// 接口定义
export interface ProtoField {
  name: string;
  type: string;
  number: number;
  required: boolean;
  description: string;
  optional?: boolean;
  repeated?: boolean;
}

export interface ProtoMessage {
  name: string;
  description: string;
  fields: ProtoField[];
}

export interface ProtoEnum {
  name: string;
  description: string;
  values: {
    name: string;
    value: number;
    description: string;
  }[];
}

// 请求消息体定义
export const requestMessages: ProtoMessage[] = [
  {
    name: 'ApiRequest',
    description: '广告报价接口请求对象',
    fields: [
      { name: 'aid', type: 'string', number: 1, required: true, description: '必填，广告位id' },
      { name: 'width', type: 'uint32', number: 2, required: true, description: '必填，广告位宽，像素' },
      { name: 'height', type: 'uint32', number: 3, required: true, description: '必填，广告位高，像素' },
      { name: 'bid', type: 'Bid', number: 4, required: false, description: '非必填，竞价配置', optional: true },
      { name: 'media', type: 'Media', number: 5, required: false, description: '必填，媒体参数', optional: true },
      { name: 'device', type: 'Device', number: 6, required: false, description: '必填，设备参数', optional: true },
      { name: 'network', type: 'Network', number: 7, required: false, description: '必填，网络参数', optional: true },
      { name: 'geo', type: 'Geo', number: 8, required: false, description: '选填，位置信息', optional: true }
    ]
  },
  {
    name: 'Bid',
    description: '竞价配置',
    fields: [
      { name: 'bidType', type: 'BidType', number: 1, required: true, description: '必填，竞价id' },
      { name: 'bidFloor', type: 'uint32', number: 2, required: true, description: '必填，竞价价格，单位：分' }
    ]
  },
  {
    name: 'Media',
    description: '媒体参数',
    fields: [
      { name: 'appId', type: 'string', number: 1, required: true, description: '必填，应用id' },
      { name: 'appName', type: 'string', number: 2, required: true, description: '必填，应用名称' },
      { name: 'appPackageId', type: 'string', number: 3, required: true, description: '必填，应用包名' },
      { name: 'appVersion', type: 'string', number: 4, required: true, description: '必填，应用版本' },
      { name: 'wechatMini', type: 'uint32', number: 5, required: false, description: '是否支持调起小程序，0：不支持，1：支持', optional: true }
    ]
  },
  {
    name: 'Device',
    description: '设备参数',
    fields: [
      { name: 'imei', type: 'string', number: 1, required: false, description: '非必填，设备imei', optional: true },
      { name: 'imeiMd5', type: 'string', number: 2, required: false, description: '非必填，设备imei md5值', optional: true },
      { name: 'anid', type: 'string', number: 3, required: false, description: '非必填，android id', optional: true },
      { name: 'anidMd5', type: 'string', number: 4, required: false, description: '非必填，android id md5值', optional: true },
      { name: 'anidAdId', type: 'string', number: 5, required: false, description: '非必填，Android 设备的 Android Advertising ID，保留原始值', optional: true },
      { name: 'oaid', type: 'string', number: 6, required: false, description: 'Android Q 及以上必填 华为设备必填', optional: true },
      { name: 'oaidMd5', type: 'string', number: 7, required: false, description: '非必填，oaid md5值', optional: true },
      { name: 'idfa', type: 'string', number: 8, required: false, description: '非必填，IOS 设备唯一标识码', optional: true },
      { name: 'idfaMd5', type: 'string', number: 9, required: false, description: '非必填，idfa md5值', optional: true },
      { name: 'idfv', type: 'string', number: 10, required: false, description: '非必填，IOS 设备的唯一标识码', optional: true },
      { name: 'idfvMd5', type: 'string', number: 11, required: false, description: '非必填，idfv md5值', optional: true },
      { name: 'openUdid', type: 'string', number: 12, required: false, description: '非必填，openudid 是苹果公司为了保护用户隐私而引入的一种设备标识符', optional: true },
      { name: 'mac', type: 'string', number: 13, required: false, description: '非必填，设备mac', optional: true },
      { name: 'brand', type: 'string', number: 14, required: false, description: '非必填，设备品牌', optional: true },
      { name: 'model', type: 'string', number: 15, required: false, description: '非必填，设备型号', optional: true },
      { name: 'deviceType', type: 'DeviceType', number: 16, required: true, description: '必填，设备类型' },
      { name: 'os', type: 'Os', number: 17, required: true, description: '必填，0 - 未知 1 - android 2 - ios 3 - harmonyOs' },
      { name: 'osVersion', type: 'string', number: 18, required: false, description: '非必填，操作系统版本', optional: true },
      { name: 'screenWidth', type: 'uint32', number: 19, required: true, description: '必填，屏幕宽度，像素' },
      { name: 'screenHeight', type: 'uint32', number: 20, required: true, description: '必填，屏幕高度，像素' },
      { name: 'orientation', type: 'Orientation', number: 21, required: true, description: '必填，屏幕方向 0 - 未知 1 - 竖屏 2 - 横屏' },
      { name: 'ua', type: 'string', number: 22, required: true, description: '必填，客户端浏览器 UserAgent 不需要 URLEncode' },
      { name: 'ip', type: 'string', number: 23, required: true, description: '必填，客户端IP地址' },
      { name: 'ipv6', type: 'string', number: 47, required: false, description: '选填，客户端IPV6地址', optional: true },
      { name: 'dpi', type: 'uint32', number: 24, required: false, description: '选填，每英寸点数', optional: true },
      { name: 'ppi', type: 'uint32', number: 25, required: false, description: '选填，每英寸像素个数', optional: true },
      { name: 'density', type: 'float', number: 26, required: false, description: '选填，屏幕密度', optional: true },
      { name: 'imsi', type: 'string', number: 27, required: false, description: '选填，IMSI 是国际移动用户识别码，用于识别移动用户的唯一标识', optional: true },
      { name: 'battery', type: 'uint32', number: 28, required: false, description: '选填，电池电量，百分比, 0 - 100', optional: true },
      { name: 'installPkg', type: 'string', number: 29, required: false, description: '选填，安装包列表', repeated: true },
      { name: 'hmsCoreVersion', type: 'string', number: 30, required: false, description: '选填，HMS Core 版本号', optional: true },
      { name: 'agVersion', type: 'string', number: 31, required: false, description: '选填，华为手机字段 ag 版本号', optional: true },
      { name: 'bootMark', type: 'string', number: 32, required: false, description: '选填，系统设备启动标识', optional: true },
      { name: 'updateMark', type: 'string', number: 33, required: false, description: '选填，系统设备更新标识', optional: true },
      { name: 'caid', type: 'string', number: 34, required: false, description: '选填，caid 原值', optional: true },
      { name: 'caidMd5', type: 'string', number: 35, required: false, description: '选填，caid加密（md5）', optional: true },
      { name: 'caidVersion', type: 'string', number: 36, required: false, description: '选填，caid 版本号', optional: true },
      { name: 'caidObject', type: 'CaidObject', number: 37, required: false, description: '选填，caid 详细信息', optional: true },
      { name: 'appstoreVersion', type: 'string', number: 38, required: true, description: '应用商店版本号' },
      { name: 'memory', type: 'string', number: 39, required: false, description: '选填，物理内存 单位KB', optional: true },
      { name: 'disk', type: 'string', number: 40, required: false, description: '选填，硬盘大小 单位KB', optional: true },
      { name: 'hardwareModel', type: 'string', number: 41, required: false, description: '选填，设备 model 值 示例："D22AP"', optional: true },
      { name: 'timeZone', type: 'string', number: 42, required: false, description: '选填，时区 示例："28800"', optional: true },
      { name: 'initTime', type: 'string', number: 43, required: false, description: '选填，设备初始化时间', optional: true },
      { name: 'bootTime', type: 'string', number: 44, required: false, description: '选填，设备最近⼀次开机时间，IOS 必传，毫秒级时间戳', optional: true }
    ]
  },
  {
    name: 'Network',
    description: '网络参数',
    fields: [
      { name: 'type', type: 'string', number: 1, required: false, description: '选填，联网方式 0：未知 1：wifi 2：2G 3：3G 4：4G 5：5G', optional: true },
      { name: 'carrier', type: 'string', number: 2, required: false, description: '选填，运营商  0：未知 1：移动 2：联通 3：电信', optional: true }
    ]
  },
  {
    name: 'Geo',
    description: '位置信息',
    fields: [
      { name: 'lat', type: 'string', number: 1, required: false, description: '选填，纬度', optional: true },
      { name: 'lng', type: 'string', number: 2, required: false, description: '选填，经度', optional: true }
    ]
  },
  {
    name: 'CaidObject',
    description: 'CAID详细信息',
    fields: [
      { name: 'hardwareMachine', type: 'string', number: 1, required: false, description: '选填，设备machine', optional: true },
      { name: 'startupTime', type: 'string', number: 2, required: false, description: '选填，设备启动时间', optional: true },
      { name: 'mbTime', type: 'string', number: 3, required: false, description: '选填，系统版本更新时间', optional: true },
      { name: 'countryCode', type: 'string', number: 4, required: false, description: '选填，国家代码', optional: true },
      { name: 'carrierName', type: 'string', number: 5, required: false, description: '选填，运营商名称', optional: true },
      { name: 'memTotal', type: 'uint32', number: 6, required: false, description: '选填，内存空间', optional: true },
      { name: 'diskTotal', type: 'uint32', number: 7, required: false, description: '选填，磁盘总空间', optional: true },
      { name: 'localTzName', type: 'string', number: 8, required: false, description: '选填，时区', optional: true },
      { name: 'hardwareModel', type: 'string', number: 9, required: false, description: '选填，设备model', optional: true },
      { name: 'iosOsVersion', type: 'string', number: 10, required: false, description: '选填，系统版本', optional: true },
      { name: 'language', type: 'string', number: 11, required: false, description: '选填，语言', optional: true },
      { name: 'phoneName', type: 'string', number: 12, required: false, description: '选填，设备名称（小写MD5)', optional: true }
    ]
  }
];

// 响应消息体定义
export const responseMessages: ProtoMessage[] = [
  {
    name: 'ApiResponse',
    description: '广告报价接口响应对象',
    fields: [
      { name: 'code', type: 'string', number: 1, required: true, description: '必填，状态码' },
      { name: 'message', type: 'string', number: 2, required: true, description: '必填，状态描述' },
      { name: 'posList', type: 'Pos', number: 3, required: true, description: '必填，广告位置', repeated: true }
    ]
  },
  {
    name: 'Pos',
    description: '广告位置',
    fields: [
      { name: 'creativeId', type: 'string', number: 1, required: true, description: '必填，广告创意 ID' },
      { name: 'impUrl', type: 'string', number: 2, required: true, description: '必填，曝光监测', repeated: true },
      { name: 'clickUrl', type: 'string', number: 3, required: true, description: '必填，点击地址' },
      { name: 'clickTrackingUrlList', type: 'string', number: 4, required: true, description: '必填，点击监测', repeated: true },
      { name: 'openType', type: 'string', number: 5, required: true, description: '必填，交互方式 0: Link 跳转 1: APP 下载 2: Deeplink 3: 微信小程序' },
      { name: 'platform', type: 'string', number: 6, required: false, description: '选填，广告预算平台类型 2：广点通特殊处理', optional: true },
      { name: 'tracking', type: 'Tracking', number: 7, required: false, description: '选填，广告监测', optional: true },
      { name: 'adIconUrl', type: 'string', number: 8, required: false, description: '选填，广告小图标地址', optional: true },
      { name: 'adLogoUrl', type: 'string', number: 9, required: false, description: '选填，广告logo 地址', optional: true },
      { name: 'combineType', type: 'string', number: 10, required: false, description: '选填，广告展示形式 ', optional: true },
      { name: 'imgUrl', type: 'string', number: 11, required: false, description: '选填，广告图片 URL', repeated: true },
      { name: 'iconUrl', type: 'string', number: 12, required: false, description: '选填，广告 Icon 图片 URL', repeated: true },
      { name: 'imageWidth', type: 'string', number: 13, required: false, description: '选填，广告图片宽，单位 pixel', optional: true },
      { name: 'imageHeight', type: 'string', number: 14, required: false, description: '选填，广告图片高，单位 pixel', optional: true },
      { name: 'title', type: 'string', number: 15, required: false, description: '选填，标题', optional: true },
      { name: 'subTitle', type: 'string', number: 16, required: false, description: '选填，副标题', optional: true },
      { name: 'desc', type: 'string', number: 17, required: false, description: '选填，广告描述', repeated: true },
      { name: 'appPackage', type: 'string', number: 18, required: false, description: '选填，下载类/Deeplink 类广告的 APP 包名', optional: true },
      { name: 'appSize', type: 'string', number: 19, required: false, description: '选填，APP 文件大小', optional: true },
      { name: 'deeplinkUrl', type: 'string', number: 20, required: false, description: '选填，Deeplink 唤醒广告打开页面 如果唤起失败则直接浏览器打开 click_link', optional: true },
      { name: 'video', type: 'Video', number: 21, required: false, description: '选填，激励视频对象', optional: true },
      { name: 'wechatMini', type: 'WechatMini', number: 22, required: false, description: '选填，微信小程序对象', optional: true },
      { name: 'bidPrice', type: 'uint32', number: 23, required: false, description: '选填，出价(单位分)', optional: true },
      { name: 'appName', type: 'string', number: 24, required: false, description: '选填，APP 名称', optional: true },
      { name: 'appVersion', type: 'string', number: 25, required: false, description: '选填，APP 版本号', optional: true },
      { name: 'appDeveloper', type: 'string', number: 26, required: false, description: '选填，APP 开发者信息', optional: true },
      { name: 'appPermission', type: 'string', number: 27, required: false, description: '选填，APP 权限', optional: true },
      { name: 'appPrivacy', type: 'string', number: 28, required: false, description: '选填，APP 隐私协议', optional: true },
      { name: 'appDesc', type: 'string', number: 29, required: false, description: '选填，APP介绍', optional: true }
    ]
  },
  {
    name: 'Tracking',
    description: '广告监测',
    fields: [
      { name: 'closeUrlList', type: 'string', number: 1, required: false, description: '选填，广告关闭监测', repeated: true },
      { name: 'startUrlList', type: 'string', number: 2, required: false, description: '选填，音频 / 视频广告开始播放监测', repeated: true },
      { name: 'fullScreenUrlList', type: 'string', number: 3, required: false, description: '选填，视频广告全屏播放监测', repeated: true },
      { name: 'endUrlList', type: 'string', number: 4, required: false, description: '选填，音频 / 视频广告结束监测', repeated: true },
      { name: 'previewUrlList', type: 'string', number: 5, required: false, description: '选填，点击预览图播放视频监测', repeated: true },
      { name: 'quarterUrlList', type: 'string', number: 6, required: false, description: '选填，音频 / 视频广告播放 1/4 进度上报监测', repeated: true },
      { name: 'halfUrlList', type: 'string', number: 7, required: false, description: '选填，音频 / 视频广告播放 1/2 进度上报监测', repeated: true },
      { name: 'thirdQuarterUrlList', type: 'string', number: 8, required: false, description: '选填，音频 / 视频广告播放 3/4 进度上报监测', repeated: true },
      { name: 'downStartUrlList', type: 'string', number: 9, required: false, description: '选填，APP 下载开始监测', repeated: true },
      { name: 'downCompleteUrlList', type: 'string', number: 10, required: false, description: '选填，APP 下载完成监测', repeated: true },
      { name: 'installStartUrlList', type: 'string', number: 11, required: false, description: '选填，APP 安装开始监测', repeated: true },
      { name: 'installCompleteUrlList', type: 'string', number: 12, required: false, description: '选填，APP 安装完成监测', repeated: true },
      { name: 'activeUrlList', type: 'string', number: 13, required: false, description: '选填，APP 激活监测', repeated: true },
      { name: 'callUrlList', type: 'string', number: 14, required: false, description: '选填，DP 成功唤起监测', repeated: true },
      { name: 'muteTrackingEvent', type: 'string', number: 15, required: false, description: '选填，视频静音监控链接', repeated: true },
      { name: 'unmuteTrackingEvent', type: 'string', number: 16, required: false, description: '选填，视频取消静音监控链接', repeated: true },
      { name: 'closeTrackingEvent', type: 'string', number: 17, required: false, description: '选填，视频关闭监控链接', repeated: true },
      { name: 'progressTrackingEvent', type: 'ProgressTrackingEvent', number: 18, required: false, description: '选填，广告激励视频播放过程监测对象', repeated: true }
    ]
  },
  {
    name: 'Video',
    description: '视频对象',
    fields: [
      { name: 'url', type: 'string', number: 1, required: false, description: '选填，视频地址', optional: true },
      { name: 'duration', type: 'string', number: 2, required: false, description: '选填，视频时长，单位为秒', optional: true },
      { name: 'width', type: 'uint32', number: 3, required: false, description: '选填，视频宽度', optional: true },
      { name: 'height', type: 'uint32', number: 4, required: false, description: '选填，视频高度', optional: true },
      { name: 'size', type: 'uint64', number: 5, required: false, description: '选填，视频大小，单位为字节', optional: true },
      { name: 'coverUrl', type: 'string', number: 6, required: false, description: '选填，视频封面图', optional: true },
      { name: 'callback', type: 'string', number: 7, required: false, description: '选填，视频观看回调，视频播放完成展示上报', optional: true },
      { name: 'endImgUrl', type: 'string', number: 8, required: false, description: '选填，视频后贴内容，一般为图片的 url，也有可能为 html 代码', optional: true },
      { name: 'endIconUrl', type: 'string', number: 9, required: false, description: '选填，视频播放完成，展示图标', optional: true },
      { name: 'endDesc', type: 'string', number: 10, required: false, description: '选填，视频播放完成，展示描述', optional: true },
      { name: 'endTitle', type: 'string', number: 11, required: false, description: '选填，视频播放完成，展示标题', optional: true },
      { name: 'endCommentCount', type: 'string', number: 12, required: false, description: '选填，视频播放完成，展示评论数', optional: true },
      { name: 'endRating', type: 'string', number: 13, required: false, description: '选填，视频播放完成，展示评分', optional: true },
      { name: 'endButtonUrl', type: 'string', number: 14, required: false, description: '选填，视频播放完成，点击按钮之后的落地页', optional: true }
    ]
  },
  {
    name: 'WechatMini',
    description: '微信小程序对象',
    fields: [
      { name: 'appId', type: 'string', number: 1, required: false, description: '选填，应用 AppID', optional: true },
      { name: 'programId', type: 'string', number: 2, required: false, description: '选填，小程序原始 ID', optional: true },
      { name: 'path', type: 'string', number: 3, required: false, description: '选填，小程序调起页面的路径', optional: true },
      { name: 'type', type: 'string', number: 4, required: false, description: '选填，小程序类型 0: 正式版 1: 开发版 2: 体验版 默认: 0', optional: true }
    ]
  },
  {
    name: 'ProgressTrackingEvent',
    description: '广告激励视频播放过程监测对象',
    fields: [
      { name: 'ms', type: 'string', number: 1, required: false, description: '选填，播放当前指定毫秒后上报', optional: true },
      { name: 'url', type: 'string', number: 2, required: false, description: '选填，监测链接', repeated: true }
    ]
  }
];

// 枚举定义
export const protoEnums: ProtoEnum[] = [
  {
    name: 'BidType',
    description: '竞价类型',
    values: [
      { name: 'CPM', value: 1, description: '默认竞价' },
      { name: 'CPC', value: 2, description: '自定义竞价' }
    ]
  },
  {
    name: 'DeviceType',
    description: '设备类型',
    values: [
      { name: 'Unknown', value: 0, description: '未知设备' },
      { name: 'Phone', value: 1, description: 'Android设备' },
      { name: 'Pad', value: 2, description: 'IOS设备' }
    ]
  },
  {
    name: 'Os',
    description: '操作系统',
    values: [
      { name: 'Unknown', value: 0, description: '未知操作系统' },
      { name: 'Android', value: 1, description: 'Android操作系统' },
      { name: 'Ios', value: 2, description: 'IOS操作系统' },
      { name: 'HarmonyOs', value: 3, description: 'HarmonyOs操作系统' }
    ]
  },
  {
    name: 'Orientation',
    description: '屏幕方向',
    values: [
      { name: 'Unknown', value: 0, description: '未知屏幕方向' },
      { name: 'Portrait', value: 1, description: '竖屏' },
      { name: 'Landscape', value: 2, description: '横屏' }
    ]
  }
];